﻿
using System;
using System.Data;
using System.Collections.Generic;

namespace LDSP.BRL
{
    public partial class Plan : BYFW.BOL.BaseEntity
    {
        public Plan()
        {
            m_tableName = "t_plan";
            m_hasName = true;
            m_hasComment = true;
            m_tblCacheManager.IsEnable = true;
        }

        protected string m_person = string.Empty;
        protected DateTime m_expiredDT = DateTime.MinValue;
        protected int m_favoriteID = 0;
        protected int m_status = 0;

        /// <summary>
        /// 相关人员
        /// </summary>
        public string Person
        {
            get { return m_person; }
            set { m_person = value; }
        }
        /// <summary>
        /// 到期时间
        /// </summary>
        public DateTime ExpiredDT
        {
            get { return m_expiredDT; }
            set { m_expiredDT = value; }
        }
        /// <summary>
        /// 收藏关系ID
        /// </summary>
        public int FavoriteID
        {
            get { return m_favoriteID; }
            set { m_favoriteID = value; }
        }
        /// <summary>
        /// 状态
        /// </summary>
        public int Status
        {
            get { return m_status; }
            set { m_status = value; }
        }

        protected override void FillContainer()
        {
            base.FillContainer();
            m_container.Add("person", m_person);
            m_container.Add("expiredDT", m_expiredDT);
            m_container.Add("favoriteID", m_favoriteID);
            m_container.Add("status", m_status);
        }

        public override bool GetProperties(System.Data.DataRow record)
        {
            if (!base.GetProperties(record))
            {
                return false;
            }
            m_person = this.GetStringValue(record, "person");
            m_expiredDT = this.GetDateValue(record, "expiredDT");
            m_favoriteID = this.GetIntValue(record, "favoriteID");
            m_status = this.GetIntValue(record, "status");
            return true;
        }

        public void DeleteByCodification(int favoriteID)
        {
            string cond = string.Format("where {0}={1}", DB.GetCol("favoriteID"), DB.GetVal(favoriteID));
            this.DeleteRecord(null, cond);
        }
    }
}

